package parser;

import java.util.List;

import represent.type.Type;
import server.SimpleDB;
import storage.transaction.Transaction;

public class InsertData extends ManipulateData {

	private String tblname;
	private List<String> flds;
	private List<Type> vals;
	private QueryData subquery;

	public InsertData(String tblname, List<String> flds, List<Type> vals) {
		this.tblname = tblname;
		this.flds = flds;
		this.vals = vals;
		subquery = null;
	}

	public InsertData(String tblname, List<String> flds, QueryData sub) {
		this.tblname = tblname;
		this.flds = flds;
		this.vals = null;
		subquery = sub;
	}

	public String tableName() {
		return tblname;
	}

	public List<String> fields() {
		return flds;
	}
	public List<Type> vals() {
		return vals;
	}

	public QueryData subquery() {
		return subquery;
	}
	
	@Override
	public int execute(Transaction tx) {
		return SimpleDB.uplanner().executeInsert(this, tx);
	}

}
